package com.itheima.consumer.listener;

import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/**
 * 短信服务-消费者监听器
 */
@Component
/**
 * topic指的是消息分类名(主题名)
 * consumerGroup指的是消费者群组名,名字自定义
 */
@RocketMQMessageListener(topic = "async-topic",consumerGroup = "smsGroup",selectorExpression = "sms")
public class SmsMessageListener implements RocketMQListener<String> {
    /**
     * 监听消息的方法
     * @param message
     */
    @Override
    public void onMessage(String message) {
        System.out.println("消费者监听到的消息是: "+message);
    }
}
